package com.zl.smartmall.library.listener;

import java.io.File;

import org.apache.http.Header;

import android.content.Context;

import com.loopj.android.http.FileAsyncHttpResponseHandler;
import com.zl.smartmall.library.util.Constants;
import com.zl.smartmall.library.util.Tools;

/**
 * 下载新版app数据请求监听器
 * @author 陈希然
 *
 */
public abstract class DownloadNewAppListener extends FileAsyncHttpResponseHandler {

	public DownloadNewAppListener(Context context) {
		super(new File(Tools.obtainDirPath(context, Constants.FOLDER_APK_CACHE), Constants.FILE_APK));
	}
	
	@Override
	public void onFailure(int statusCode, Header[] headers,
			Throwable throwable, File file) {
		// TODO Auto-generated method stub
		onResponseFailed();
	}

	@Override
	public void onSuccess(int statusCode, Header[] headers, File file) {
		// TODO Auto-generated method stub
		onResponseSuccess(file);
	}
	
	/**
	 * 无网络连接
	 */
	public abstract void onNoNetWork();
	
	/**
	 * 下载新版apk失败
	 */
	public abstract void onResponseFailed();
	
	/**
	 * 下载新版apk成功
	 */
	public abstract void onResponseSuccess(File file);

}
